#ifndef USER_INFO_COMMAND_H_
#define USER_INFO_COMMAND_H_

#include "command.h"

#ifdef _WIN32
#pragma warning( push )
#pragma warning( disable : 4200 )
#endif

#pragma pack(1)
namespace Cmd
{
        enum //CMD_USERINFO
        {
                SCMD_USERINFO_NULL	                = 0x0000,
                SCMD_USERINFO_UPDATE_NICKNAME           = 0x0001,       // 更新昵称
                SCMD_USERINFO_UPDATE_NICKNAME_RES       = 0x0002,       // 更新昵称返回
                SCMD_USERINFO_UPDATE_MOOD               = 0x0003,       // 更新心情
                SCMD_USERINFO_UPDATE_MOOD_RES           = 0x0004,       // 更新心情返回
                SCMD_USERINFO_SET_ACCEPT_STRANGER_MSG   = 0x0005,       // 设置接收陌生人消息
                SCMD_USERINFO_SET_ACCEPT_STRANGER_MSG_RES       = 0x0006,       // 设置接收陌生人消息返回
                SCMD_USERINFO_REQ_ROOM_LIST             = 0x0007,       // 请求房间列表
                SCMD_USERINFO_RES_ROOM_LIST             = 0x0008,       // 请求房间列表返回
                SCMD_USERINFO_COLLECT_ROOM_REQ          = 0x0009,       // 请求收藏房间
                SCMD_USERINFO_COLLECT_ROOM_RES          = 0x000A,       // 请求收藏房间返回
                SCMD_USERINFO_SEND_ALL_ROOM_LIST        = 0x000B,       // 发送所有房间的列表信息给用户
                SCMD_USERINFO_LAST_CONTACT_LIST         = 0x000C,       // NOT USE.
                SCMD_USERINFO_REQ_OFFLINE_MSG           = 0x000D,       // 用户登陆后请求离线消息
                SCMD_USERINFO_REPORT_CMD_VERSION        = 0x000E,       // 用户的协议版本
                SCMD_USERINFO_COLLECT_ROOM_LIST_REQ     = 0x000F,       // 请求收藏房间列表
                SCMD_USERINFO_COLLECT_ROOM_LIST_RES     = 0x0010,       // 请求收藏房间列表-返回
                SCMD_USERINFO_ROOM_SIMPLE_INFO_REQ      = 0x0011,
                SCMD_USERINFO_ROOM_SIMPLE_INFO_RES      = 0x0012,
                SCMD_USERINFO_ONLINE_TIME_REQ           = 0x0013,       //请求在线时长
                SCMD_USERINFO_ONLINE_TIME_RES           = 0x0014,       //返回在线时长
                SCMD_USERINFO_LAST_CONTACT_LIST_NEW     = 0x0015,       //返回最近联系人列表（只包括好友）
                SCMD_USERINFO_CONTACT_LIST_REQ          = 0x0016,       //登录成功后请求最近联系人列表（只包括好友）
                SCMD_USERINFO_HISTORY_ROOM_LIST_REQ     = 0x0017,
                SCMD_USERINFO_HISTORY_ROOM_LIST_RET     = 0x0018,
                SCMD_USERINFO_SEND_FLOWER_REQ           = 0x0019,       //c->s 用户请求自己的鲜花数量
                SCMD_USERINFO_SEND_FLOWER_RET           = 0x001A,       //s->c 用户请求自己的鲜花数量 返回
                SCMD_USERINFO_SEND_FLOWER_NOTIFY        = 0x001B,       //s->c 用户娴熟数量增长 通知
                SCMD_USERINFO_TASK_LIST_REQ             = 0x001C,       //c->s 用户请求任务列表
                SCMD_USERINFO_TASK_LIST_RES             = 0x001D,       //s->c 用户请求任务列表 返回
                SCMD_USERINFO_MY_TASK_STAT_REQ          = 0x001E,       //c->s 用户请求自己的任务状态
                SCMD_USERINFO_MY_TASK_STAT_RES          = 0x001F,       //s->c 用户请求自己的任务状态 返回
                SCMD_USERINFO_TASK_REWARD_REQ           = 0x0020,       //c->s 用户领取奖励
                SCMD_USERINFO_TASK_REWARD_RES           = 0x0021,       //s->c 用户领取奖励 返回
                SCMD_USERINFO_TASK_SIGN_IN              = 0x0022,       //c->s 用户执行签到任务
                SCMD_USERINFO_TASK_COURSE_EVAL          = 0x0023,       //c->s 用户执行了课程评价
                SCMD_USERINFO_TASK_LAST_REWARD_NOTIFY   = 0x0024,       //s->c 通知用户上次登录获得的奖励已经到账
                SCMD_USERINFO_NOTIFY_ACTIVATE_ACC       = 0x0025,       //s->c 提醒用户激活帐号
                SCMD_USERINFO_USER_IP_REQ               = 0x0028,       //c->s 请求用户出口IP
                SCMD_USERINFO_USER_IP_RET               = 0x0029,       //s->c 返回用户出口IP
                SCMD_USERINFO_STABLE_OPTION_REQ         = 0x002A,       //c->s 移动设备请求选项设置（用户设置）
                SCMD_USERINFO_STABLE_OPTION_RET         = 0x002B,       //s->c 移动设备返回选项设置结果（用户设置）
                SCMD_USERINFO_STABLE_OPTION_SET_REQ     = 0x002C,       //c->s 移动设备请求设置选项（用户设置）
                SCMD_USERINFO_STABLE_OPTION_SET_RET     = 0x002D,       //s->c 移动设备返回设置选项结果（用户设置）
                SCMD_USERINFO_FLEXIBLE_OPTION_NOTIFY    = 0x002E,       //c->s 移动设备选项设置通知（动态设置）
        };

        struct stUserInfoCmd:
                t_NullCmd
        {
                stUserInfoCmd(uint16_t scmd):
                        t_NullCmd(CMD_USERINFO, scmd)
                {
                }
        };

        struct stUserInfoUpdateNickName:
                t_NullCmd
        {
                stUserInfoUpdateNickName():
                        t_NullCmd(CMD_USERINFO, SCMD_USERINFO_UPDATE_NICKNAME)
                {
                        bzero(nick_name_, sizeof(nick_name_));
                }
                BYTE nick_name_[MAX_NAME_SIZE+1];  // 用户昵称
        };
        struct stUserInfoUpdateNickNameRes:
                t_NullCmd
        {
                stUserInfoUpdateNickNameRes():
                        t_NullCmd(CMD_USERINFO, SCMD_USERINFO_UPDATE_NICKNAME_RES)
                {
                        bzero(nick_name_, sizeof(nick_name_));
                        ret_code_ = 0;
                }
                BYTE nick_name_[MAX_NAME_SIZE + 1];  // 用户昵称
                BYTE ret_code_; //0-fail;1-success
        };
        struct stUserInfoUpdateMood:
                t_NullCmd
        {
                stUserInfoUpdateMood():
                        t_NullCmd(CMD_USERINFO, SCMD_USERINFO_UPDATE_MOOD)
                {
                        bzero(mood_, sizeof(mood_));
                }
                BYTE mood_[MAX_MOOD_SIZE+1];  // 个人签名
        };
        struct stUserInfoUpdateMoodRes:
                t_NullCmd
        {
                stUserInfoUpdateMoodRes():
                        t_NullCmd(CMD_USERINFO, SCMD_USERINFO_UPDATE_MOOD_RES)
                {
                        bzero(mood_, sizeof(mood_));
                        ret_code_ = 0;
                }
                BYTE mood_[MAX_MOOD_SIZE+1];  // 个人签名
                BYTE ret_code_; //0-fail; 1-success
        };
        struct stUserInfoSetAcceptStrangerMsg:
                t_NullCmd
        {
                stUserInfoSetAcceptStrangerMsg():
                        t_NullCmd(CMD_USERINFO, SCMD_USERINFO_SET_ACCEPT_STRANGER_MSG)
                {
                        accept_ = 0;
                }
                BYTE accept_; //0-not accept; 1-accept
        };
        struct stUserInfoSetAcceptStrangerMsgRes:
                t_NullCmd
        {
                stUserInfoSetAcceptStrangerMsgRes():
                        t_NullCmd(CMD_USERINFO, SCMD_USERINFO_SET_ACCEPT_STRANGER_MSG_RES)
                {
                        accept_ = 0;
                        ret_code_ = 0;
                }
                BYTE accept_;	//0-not accept; 1-accept
                BYTE ret_code_;	//0-fail; 1-success
        };
        struct stUserInfoReqRoomList:
                t_NullCmd
        {
                stUserInfoReqRoomList():
                        t_NullCmd(CMD_USERINFO, SCMD_USERINFO_REQ_ROOM_LIST)
                {
                        type_ = eRoomListType_null;
                }
                BYTE type_;     //eRoomListType
        };
        struct stUserInfoResRoomList:
                t_NullCmd
        {
                stUserInfoResRoomList():
                        t_NullCmd(CMD_USERINFO, SCMD_USERINFO_RES_ROOM_LIST)
                {
                        type_ = eRoomListType_null;
                        begin_ = 0;
                        finish_ = 0;
                        room_num_ = 0;
                }
                BYTE type_;     //eRoomListType
                BYTE begin_;    //0-not begin, 1-begin
                BYTE finish_;   //0-not finish, 1-finish
                WORD room_num_;  // 房间ID个数
                DWORD room_list_[0];  // 房间ID列表
                DWORD getSize() {
                        return sizeof(*this)+room_num_*sizeof(room_list_[0]);
                }
        };
        //请求收藏/取消收藏某个房间
        struct stUserInfoCollectRoomReq:
                t_NullCmd
        {
                stUserInfoCollectRoomReq():
                        t_NullCmd(CMD_USERINFO, SCMD_USERINFO_COLLECT_ROOM_REQ)
                {
                        type_ = 0;
                        room_id_ = 0;
                }
                BYTE type_;     //0-add collection; 1-del collection
                DWORD room_id_;  // 房间ID
        };
        struct stUserInfoCollectRoomRes:
                t_NullCmd
        {
                stUserInfoCollectRoomRes():
                        t_NullCmd(CMD_USERINFO, SCMD_USERINFO_COLLECT_ROOM_RES)
                {
                        type_ = 0;
                        room_id_ = 0;
                        ret_code_ = 0;
                }
                BYTE type_;     //0-add collection; 1-del collection
                DWORD room_id_;  // 房间ID
                BYTE ret_code_; //0-fail; 1-success; 2-full
        };

        struct stUserInfoResAllRoomList:
                t_NullCmd
        {
                stUserInfoResAllRoomList():
                        t_NullCmd(CMD_USERINFO, SCMD_USERINFO_SEND_ALL_ROOM_LIST)
                {
                        num_ = 0;
                        finish_ = 0;
                }
                WORD num_;  // 房间信息个数
                BYTE finish_; //0-not finish, 1-finish
                struct stRoomShowInfo{
                        DWORD id_;                              //房间id
                        BYTE type_;                              // 房间类型
                        char name_[MAX_ROOM_NAME_SIZE+1];       //房间名
                        char avatar_[MAX_AVATAR_SIZE+1];        //图标url
                        char desc_[MAX_ROOM_DESC_SIZE+1];       //房间描述
                } room_list_[0];  // 房间信息列表
                DWORD getSize() {
                        return sizeof(*this)+num_*sizeof(room_list_[0]);
                }
        };
        struct stUserInfoReqOfflineMsg:
                t_NullCmd
        {
                stUserInfoReqOfflineMsg():
                        t_NullCmd(CMD_USERINFO, SCMD_USERINFO_REQ_OFFLINE_MSG)
                {
                }
        };
        struct stUserInfoReportCmdVersion:
                t_NullCmd
        {
                stUserInfoReportCmdVersion():
                        t_NullCmd(CMD_USERINFO, SCMD_USERINFO_REPORT_CMD_VERSION)
                {
                        version_ = DEFAULT_CMD_VERSION;
                }
                void setVersion(const DWORD &ver)
                {
                        version_ = ver;
                }
                DWORD getVersion() const 
                {
                        return version_;
                }

                DWORD version_;  // 版本号
        };
        struct stUserInfoCollectRoomListReq:
                t_NullCmd
        {
                stUserInfoCollectRoomListReq():
                        t_NullCmd(CMD_USERINFO, SCMD_USERINFO_COLLECT_ROOM_LIST_REQ)
                {
                }
        };
        struct stUserInfoCollectRoomListRes:
                t_NullCmd
        {
                stUserInfoCollectRoomListRes():
                        t_NullCmd(CMD_USERINFO, SCMD_USERINFO_COLLECT_ROOM_LIST_RES)
                {
                        num_ = 0;
                }
                WORD num_;  // ID个数
                DWORD list_[0];  // ID列表
                DWORD getSize() {
                        return sizeof(*this)+num_*sizeof(list_[0]);
                }
        };
        struct stUserInfoRoomSimpleInfoReq:
                t_NullCmd
        {
                stUserInfoRoomSimpleInfoReq():
                        t_NullCmd(CMD_USERINFO, SCMD_USERINFO_ROOM_SIMPLE_INFO_REQ)
                {
                        num_ = 0;
                }
                WORD num_;  // ID个数
                DWORD room_id_list_[0]; //room id list
                DWORD getSize() {
                        return sizeof(*this)+num_*sizeof(room_id_list_[0]);
                }
        };
        struct stUserInfoRoomSimpleInfoRes:
                t_NullCmd
        {
                stUserInfoRoomSimpleInfoRes():
                        t_NullCmd(CMD_USERINFO, SCMD_USERINFO_ROOM_SIMPLE_INFO_RES)
                {
                        room_id_ = 0;
                        bzero(room_name_, sizeof(room_name_));
                }
                DWORD room_id_;  // 房间ID
                char room_name_[MAX_ROOM_NAME_SIZE+1];  // 房间名称
        };
        struct stUserInfoOnlineTimeReq:
                t_NullCmd
        {
                stUserInfoOnlineTimeReq():
                        t_NullCmd(CMD_USERINFO, SCMD_USERINFO_ONLINE_TIME_REQ)
                {
                }
        };
        struct stUserInfoOnlineTimeRes:
                t_NullCmd
        {
                stUserInfoOnlineTimeRes():
                        t_NullCmd(CMD_USERINFO, SCMD_USERINFO_ONLINE_TIME_RES)
                {
                        online_time_ = 0;
                }
                DWORD online_time_;  // 在线时间
        };
        struct stUserInfoContactListReq:
                t_NullCmd
        {
                stUserInfoContactListReq():
                        t_NullCmd(CMD_USERINFO, SCMD_USERINFO_CONTACT_LIST_REQ)
                {
                }
        };
        struct stUserInfoLastContactListNew:
                t_NullCmd
        {
                stUserInfoLastContactListNew():
                        t_NullCmd(CMD_USERINFO, SCMD_USERINFO_LAST_CONTACT_LIST_NEW)
                {
                        num_ = 0;
                        finish_ = 0;
                }
                WORD num_;      //信息个数, max 50
                BYTE finish_;   //0-not finish, 1-finish
                struct stLC {
                        DWORD userid;  // 用户ID
                        DWORD contacttime;  // 联系时间
                } list_[0];  // 信息列表
                DWORD getSize() {
                        return sizeof(*this)+num_*sizeof(list_[0]);
                }
        };
        struct stUserInfoHistoryRoomListReq:
                t_NullCmd
        {
                stUserInfoHistoryRoomListReq():
                        t_NullCmd(CMD_USERINFO, SCMD_USERINFO_HISTORY_ROOM_LIST_REQ)
                {
                }
        };
        struct stUserInfoHistoryRoomListRet:
                t_NullCmd
        {
                stUserInfoHistoryRoomListRet():
                        t_NullCmd(CMD_USERINFO, SCMD_USERINFO_HISTORY_ROOM_LIST_RET)
                {
                        clear_ = 0;
                        size_ = 0;
                }

                uint32_t getSize() const
                {
                        return sizeof(*this) + size_*sizeof(list_[0]);
                }

                uint8_t clear_;  // 清除标识
                uint16_t size_;  // 列表个数
                struct stUT {
                        uint32_t room_id_;  // 房间ID
                        uint32_t leave_time_;  // 离开时间
                } list_[0];  // 房间历史列表
        };
        struct stUserInfoSendFlowerReq:
                t_NullCmd
        {
                stUserInfoSendFlowerReq():
                        t_NullCmd(CMD_USERINFO, SCMD_USERINFO_SEND_FLOWER_REQ)
                {
                }
        };
        struct stUserInfoSendFlowerRet:
                t_NullCmd
        {
                stUserInfoSendFlowerRet():
                        t_NullCmd(CMD_USERINFO, SCMD_USERINFO_SEND_FLOWER_RET)
                {
                        send_flower_ = 0;
                }

                uint8_t send_flower_;   //用户可送鲜花数量
        };
        struct stUserInfoSendFlowerNotify:
                t_NullCmd
        {
                stUserInfoSendFlowerNotify():
                        t_NullCmd(CMD_USERINFO, SCMD_USERINFO_SEND_FLOWER_NOTIFY)
                {
                        send_flower_ = 0;
                }

                uint8_t send_flower_;   //用户可送鲜花数量
        };
        struct stUserInfoTaskListReq:
                stUserInfoCmd
        {
                stUserInfoTaskListReq():
                        stUserInfoCmd(SCMD_USERINFO_TASK_LIST_REQ)
                {
                }
        };

        struct stUserInfoTaskListRes:
                stUserInfoCmd
        {
                stUserInfoTaskListRes():
                        stUserInfoCmd(SCMD_USERINFO_TASK_LIST_RES)
                {
                        task_len = 0;
                }
                uint32_t get_size()
                {
                        return sizeof(*this)+task_len*sizeof(task_info[0]);
                }
                uint32_t task_len; //task_info的长度
                char task_info[0]; //json
                //格式如下:
                //{"tasks":
                //      [
                //      {"id":1,"act":"签到","nums":{"n1":1}},
                //      {"id":2,"act":"听课","nums":{"n1":1,"n2":30}},
                //      {"id":3,"act":"听课","nums":{"n1":1,"n2":1}},
                //      ]
                //}
                //
                //字段说明：
                //      id:     任务id.
                //      act:    任务动作.
                //      nums:   相关数值. n1:奖励 n2..nx其他相关数值
        };

        struct stUserInfoMyTaskStatReq:
                stUserInfoCmd
        {
                stUserInfoMyTaskStatReq():
                        stUserInfoCmd(SCMD_USERINFO_MY_TASK_STAT_REQ)
                {
                }
        };

        struct stUserInfoMyTaskStatRes:
                stUserInfoCmd
        {
                stUserInfoMyTaskStatRes():
                        stUserInfoCmd(SCMD_USERINFO_MY_TASK_STAT_RES)
                {
                        task_len = 0;
                }
                uint32_t get_size()
                {
                        return sizeof(*this) + task_len*sizeof(task_info[0]);
                }
                uint32_t task_len; //task_info的长度
                char task_info[0]; //json格式
                //格式如下:
                //{"stats":
                //      [
                //      {"id":1,"st":2,"progress":{"p1":0}},
                //      {"id":2,"st":0,"progress":{"p1":30}},
                //      {"id":3,"st":1,"progress":{"p1":1234,"p2":10}},
                //      ]
                //}
                //
                //字段说明：
                //      id:     任务id.
                //      st:     状态. eUserTaskState
                //      progress:   任务进度.
        };

        struct stUserInfoTaskRewardReq:
                stUserInfoCmd
        {
                stUserInfoTaskRewardReq():
                        stUserInfoCmd(SCMD_USERINFO_TASK_REWARD_REQ)
                {
                        task_id = 0;
                }
                uint16_t task_id; //任务id
        };

        struct stUserInfoTaskRewardRes:
                stUserInfoCmd
        {
                stUserInfoTaskRewardRes():
                        stUserInfoCmd(SCMD_USERINFO_TASK_REWARD_RES)
                {
                        task_id = 0;
                        success = 0;
                }
                uint16_t task_id; //任务id
                uint8_t  success; //0-yes 1-no
        };

        struct stUserInfoTaskSignIn:
                stUserInfoCmd
        {
                stUserInfoTaskSignIn():
                        stUserInfoCmd(SCMD_USERINFO_TASK_SIGN_IN)
                {
                }
        };
        struct stUserInfoTaskCourseEval:
                stUserInfoCmd
        {
                stUserInfoTaskCourseEval():
                        stUserInfoCmd(SCMD_USERINFO_TASK_COURSE_EVAL)
                {
                }
        };
        struct stUserInfoTaskLastRewardNotify:
                stUserInfoCmd
        {
                stUserInfoTaskLastRewardNotify():
                        stUserInfoCmd(SCMD_USERINFO_TASK_LAST_REWARD_NOTIFY)
                {
                        info_len = 0;
                }
                uint32_t info_len; //info的长度
                char info[0]; //json格式
                uint32_t get_size()
                {
                        return sizeof(*this) + info_len*sizeof(info[0]);
                }
                //json format:
                //{"lastreward":
                //      [
                //              {"type":1, "num":3},
                //              {"type":2, "num":10}
                //      ]
                //}
                //字段说明:
                //type: 奖励类型 1为鲜花
                //num: 奖励的数量
        };
        struct stUserInfoNotifyActivateAcc:
                stUserInfoCmd
        {
                stUserInfoNotifyActivateAcc():
                        stUserInfoCmd(SCMD_USERINFO_NOTIFY_ACTIVATE_ACC)
                {
                }
        };

        struct stUserInfoUserIpReq:
                stUserInfoCmd
        {
                stUserInfoUserIpReq():
                        stUserInfoCmd(SCMD_USERINFO_USER_IP_REQ)
                {
                }
        };
        struct stUserInfoUserIpRet:
                stUserInfoCmd
        {
                stUserInfoUserIpRet():
                        stUserInfoCmd(SCMD_USERINFO_USER_IP_RET)
                {
                        ip_ = 0;
                }

                uint32_t ip_;                   // 用户出口IP
        };

        struct stUserInfoStableOptionReq:
                stUserInfoCmd
        {
                stUserInfoStableOptionReq():
                        stUserInfoCmd(SCMD_USERINFO_STABLE_OPTION_REQ)
                {
                }
        };
        struct stUserInfoStableOptionRet:
                stUserInfoCmd
        {
                stUserInfoStableOptionRet():
                        stUserInfoCmd(SCMD_USERINFO_STABLE_OPTION_RET)
                {
                        size_ = 0;
                }

                uint32_t getSize() const
                {
                        return sizeof(*this) + size_*sizeof(json_[0]);
                }

                uint16_t size_;                 // 选项长度
                char json_[0];                  // 选项内容
                // json_ = sound(bool) + vib(bool)
        };

        struct stUserInfoStableOptionSetReq:
                stUserInfoCmd
        {
                stUserInfoStableOptionSetReq():
                        stUserInfoCmd(SCMD_USERINFO_STABLE_OPTION_SET_REQ)
                {
                        size_ = 0;
                }

                uint32_t getSize() const
                {
                        return sizeof(*this) + size_*sizeof(json_[0]);
                }

                uint16_t size_;                 // 选项长度
                char json_[0];                  // 选项内容
                // json_ = sound(bool) + vib(bool)
        };
        struct stUserInfoStableOptionSetRet:
                stUserInfoCmd
        {
                stUserInfoStableOptionSetRet():
                        stUserInfoCmd(SCMD_USERINFO_STABLE_OPTION_SET_RET)
                {
                        ret_code_ = 0;
                }

                uint8_t ret_code_;              // 0 for success, 非0 for failure
        };

        struct stUserInfoFlexibleOptionSetNotify:
                stUserInfoCmd
        {
                stUserInfoFlexibleOptionSetNotify():
                        stUserInfoCmd(SCMD_USERINFO_FLEXIBLE_OPTION_NOTIFY)
                {
                        size_ = 0;
                }

                uint32_t getSize() const
                {
                        return sizeof(*this) + size_*sizeof(json_[0]);
                }

                uint16_t size_;                 // 选项长度
                char json_[0];                  // 选项内容
                // json_ = push(bool) + sound(bool) + vib(bool)
        };
};//namespace Cmd
#pragma pack()

#ifdef _WIN32
#pragma warning( pop )
#endif

#endif //USER_INFO_COMMAND_H_
